package cn.golxen.counter.controller;


import cn.golxen.commons.entity.Result;
import cn.golxen.commons.vo.CounterVO;
import cn.golxen.counter.entity.Suspend;
import cn.golxen.counter.service.SuspendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/counter")
public class SuspendController {

    @Autowired
    SuspendService suspendService;

    @PostMapping(value = "/addsuspend")
    public Result addSuspend(List<Suspend> suspend){
        Integer integer=suspendService.addSuspend(suspend);
        return Result.successResult(integer);
    }

    @PostMapping(value = "/deletesuspend")
    public Result deleteSuspend(List<Suspend> suspend){
        Integer integer=suspendService.deleteSuspend(suspend);
        return Result.successResult(integer);
    }

    @PostMapping(value = "/sellsuspend")
    public Result sellSuspend(List<Suspend> suspend){
        Integer integer=suspendService.sellSuspend(suspend);
        if (integer!=0)
            return Result.successResult(integer);
        else
            return new Result(11,"挂起结账失败");
    }

    @GetMapping(value = "/get")
    public Result getSuspend(){
        return Result.successResult(suspendService.getSuspend());
    }
}
